mac80211: rtl8xxxu: sync with linux-next 20240229
[openwrt/staging/mans0n.git] / package / kernel / mac80211 / patches / rtl / 001-05-v6.9-wifi-rtl8xxxu-support-setting-mac-address-register-f.patch
1 From 00add60cad3c9690ac0f9d4f6685f96ccd607670 Mon Sep 17 00:00:00 2001
2 From: Martin Kaistra <martin.kaistra@linutronix.de>
3 Date: Fri, 22 Dec 2023 11:14:26 +0100
4 Subject: [PATCH 05/21] wifi: rtl8xxxu: support setting mac address register
5 for both interfaces
6
7 To prepare for concurrent mode, enhance rtl8xxxu_set_mac() to write the
8 mac address of the respective interface to REG_MACID or REG_MACID1.
9
10 Remove the call to rtl8xxxu_set_mac() from the init function as we set
11 it in rtl8xxxu_add_interface() later anyway.
12
13 Until rtl8xxxu_add_interface() can handle both interfaces, call
14 rtl8xxxu_set_mac() with port_num = 0.
15
16 Signed-off-by: Martin Kaistra <martin.kaistra@linutronix.de>
17 Reviewed-by: Ping-Ke Shih <pkshih@realtek.com>
18 Signed-off-by: Kalle Valo <kvalo@kernel.org>
19 Link: https://msgid.link/20231222101442.626837-6-martin.kaistra@linutronix.de
20 ---
21 .../wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 20 +++++++++++++------
22 1 file changed, 14 insertions(+), 6 deletions(-)
23
24 --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
25 +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
26 @@ -3580,15 +3580,25 @@ void rtl8723a_phy_lc_calibrate(struct rt
27 rtl8xxxu_write8(priv, REG_TXPAUSE, 0x00);
28 }
29
30 -static int rtl8xxxu_set_mac(struct rtl8xxxu_priv *priv)
31 +static int rtl8xxxu_set_mac(struct rtl8xxxu_priv *priv, int port_num)
32 {
33 int i;
34 u16 reg;
35
36 - reg = REG_MACID;
37 + switch (port_num) {
38 + case 0:
39 + reg = REG_MACID;
40 + break;
41 + case 1:
42 + reg = REG_MACID1;
43 + break;
44 + default:
45 + WARN_ONCE("%s: invalid port_num\n", __func__);
46 + return -EINVAL;
47 + }
48
49 for (i = 0; i < ETH_ALEN; i++)
50 - rtl8xxxu_write8(priv, reg + i, priv->mac_addr[i]);
51 + rtl8xxxu_write8(priv, reg + i, priv->vifs[port_num]->addr[i]);
52
53 return 0;
54 }
55 @@ -4243,8 +4253,6 @@ static int rtl8xxxu_init_device(struct i
56 rtl8xxxu_write32(priv, REG_HIMR, 0xffffffff);
57 }
58
59 - rtl8xxxu_set_mac(priv);
60 -
61 /*
62 * Configure initial WMAC settings
63 */
64 @@ -6619,7 +6627,7 @@ static int rtl8xxxu_add_interface(struct
65
66 rtl8xxxu_set_linktype(priv, vif->type, 0);
67 ether_addr_copy(priv->mac_addr, vif->addr);
68 - rtl8xxxu_set_mac(priv);
69 + rtl8xxxu_set_mac(priv, 0);
70
71 return ret;
72 }